<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="./js/vue.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/vuex/3.2.0/vuex.min.js"></script>
    <title>Document</title>
  </head>
  <body>
    <div id="app">姓名：{{fullName}}</div>
  </body>
  <script>
    var app = new Vue({
      el: "#app",
      data: {
        firstName: "Jack",
        lastName: "Green"
      },
      computed: {
        fullName: {
          // getter   用于读取
          get: function () {
            return this.firstName + "" + this.lastName
          },
          // setter   写入时触发
          set: function () {
            var names = newValue.split("")
            this.firstName = names[0]
            this.lastName = names[names.length - 1]
          }
        }
      }
    })
  </script>
  <!-- 计算属性
    每一个计算属性都包含一个getter和一个setter。
    setter函数，执行一些自定义的操作；getter函数用来读取
--></html>
